<extend name="public@base5" />
<block name="main">
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link active" href="{:url('IMSession/index')}">聊天列表</a>
            </li>
        </ul>
        <form class="well form-inline margin-top-20 bg-white" method="get" action="{:url('IMSession/index')}">
            发送时间:
            <input type="text" class="js-bootstrap-date form-control form-check-inline" name="start_time"
                value="{$start_time|default=''}" style="width: 140px;" autocomplete="off">-
            <input type="text" class="js-bootstrap-date form-control form-check-inline" name="end_time"
                value="{$end_time|default=''}" style="width: 140px;" autocomplete="off">
            &nbsp;
            <input type="text" class="form-control form-check-inline" name="user_id" style="width: 200px;" value="{$user_id|default=''}" 
                placeholder="请输入用户ID" oninput="limitInputNumberLength(this, 12)">
            &nbsp;
            <input type="text" class="form-control form-check-inline" name="mobile" style="width: 200px;"
                value="{$mobile|default=''}" placeholder="请输入手机号码" oninput="limitInputNumberLength(this, 11)">
            状态:
            <select class="form-control form-check-inline" name="session_status" style="width: 140px;">
                <php>$status_selected1=!empty($session_status)&&$session_status==1?"selected":"";</php>
                <php>$status_selected2=!empty($session_status)&&$session_status==2?"selected":"";</php>
                <php>$status_selected0=!empty($session_status)&&$session_status==0?"selected":"";</php>
                <option value='0' {$status_selected0}></option>
                <option value='1' {$status_selected1}>正常</option>
                <option value='2' {$status_selected2}>禁言</option>
            </select> &nbsp;
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('IMSession/index')}">清空</a>
        </form>
        <table class="table table-hover table-bordered margin-top-20">
            <thead>
                <tr>
                    <th width="50">序号</th>
                    <th>发送人</th>
                    <th>发送人手机号</th>
                    <th>接收人</th>
                    <th>发送时间</th>
                    <th>状态</th>
                    <th width="120">{:lang('ACTIONS')}</th>
                </tr>
            </thead>
            <tbody>
                <php>
                    $session_statuses=['正常', '已禁言'];
                </php>
                <foreach name="items" item="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>
                            <div style="display: flex; align-items: center;">
                                <a style="text-decoration: none;"
                                    href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.send_avatar)}');">
                                    <img width="50" height="50" src="{:cmf_get_image_url($vo.send_avatar)}">
                                </a>
                                <div style="margin-left: 10px;">
                                    <p style="margin: 0;">ID：{$vo.send_user_id}</p>
                                    <p style="margin: 0;">{$vo.send_nickname}</p>
                                </div>
                            </div>
                        </td>
                        <td>{$vo.send_mobile}</td>
                        <td>
                            <if condition="$vo.receive_user_id == 0">
                                世界聊天
                                <else />
                                <div style="display: flex; align-items: center;">
                                    <a
                                        href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.receive_avatar)}');">
                                        <img width="50" height="50" src="{:cmf_get_image_url($vo.receive_avatar)}">
                                    </a>
                                    <div style="margin-left: 10px;">
                                        <p style="margin: 0;">ID：{$vo.receive_user_id}</p>
                                        <p style="margin: 0;">{$vo.receive_nickname}</p>
                                    </div>
                                </div>
                            </if>
                        </td>
                        <td>{:date('Y-m-d H:i:s',$vo['update_time'])}</td>
                        <td>
                            <span>{$session_statuses[$vo['session_status']]}</span>
                        </td>
                        <td>
                            <if condition="$vo['session_status'] eq 0">
                                <a class="btn btn-xs btn-warning js-ajax-dialog-btn"
                                   href="javascript:"
                                   data-href="admin/im/session/{$vo.id}/status/1"
                                   data-msg="是否禁言"
                                   title="禁言" data-toggle="tooltip">
                                   禁言
                                </a>
                                <else/>
                                <a class="btn btn-xs btn-success js-ajax-dialog-btn"
                                   href="javascript:"
                                   data-href="admin/im/session/{$vo.id}/status/0"
                                   data-msg="是否取消禁言"
                                   title="取消禁言" data-toggle="tooltip">
                                   取消禁言
                                </a>
                            </if>
                        </td>
                    </tr>
                </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </div>
</block>